package com.fita.admin.entity.search.currency;

import com.demo2do.core.persistence.support.QueryBuilder;
import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;

import java.util.Map;
/**
 * 
 * @author cuteHU
 *
 */
public class ExchangeRateSearch implements QueryBuilder {

    /** 货币名称 */
    private String currencyName;

    /** 货币代码 */
    private String currencyCode;

    private QueryFilter queryFilter;

    private QueryOrder queryOrder;

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(boolean)
     */
    public QueryFilter getPreparedFilter(boolean refresh) {
        if (queryFilter == null || refresh) {

            queryFilter = new QueryFilter();

            queryFilter.addLike("currencyName", currencyName).addLike("currencyCode", currencyCode);
        }

        return queryFilter;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#getOrder()
     */
    public QueryOrder getOrder() {
        if (queryOrder == null) {
            queryOrder = new QueryOrder();
        }
        return queryOrder;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
    public String buildSentenceTemplate() {
        return "FROM ExchangeRate " + getPreparedFilter(false).whereSentence();
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {
        return getPreparedFilter(false).parameters();
    }

    /**
     * @return the currencyName
     */
    public String getCurrencyName() {
        return currencyName;
    }

    /**
     * @return the currencyCode
     */
    public String getCurrencyCode() {
        return currencyCode;
    }

    /**
     * @return the queryFilter
     */
    public QueryFilter getQueryFilter() {
        return queryFilter;
    }

    /**
     * @return the queryOrder
     */
    public QueryOrder getQueryOrder() {
        return queryOrder;
    }

    /**
     * @param currencyName the currencyName to set
     */
    public void setCurrencyName(String currencyName) {
        this.currencyName = currencyName;
    }

    /**
     * @param currencyCode the currencyCode to set
     */
    public void setCurrencyCode(String currencyCode) {
        this.currencyCode = currencyCode;
    }

    /**
     * @param queryFilter the queryFilter to set
     */
    public void setQueryFilter(QueryFilter queryFilter) {
        this.queryFilter = queryFilter;
    }

    /**
     * @param queryOrder the queryOrder to set
     */
    public void setQueryOrder(QueryOrder queryOrder) {
        this.queryOrder = queryOrder;
    }

}
